var total_best_page = 3;
var best_start_like = 10000;
var best_end_like = 50000;


function getrandom(a,b){
	return (a + Math.floor(Math.random()*(b-a)));
}

document.getElementById("total_like1").value = getrandom(best_start_like,best_end_like);

function plus_like1(){
    document.getElementById("total_like1").value++;
}

function minus_like1(){
    document.getElementById("total_like1").value--;
}

function generate_zero_number(number) {
    if (number<10) {
        number = "0" + number;
    }
    return number;
}

function submit_comment(userName,idComment) {

    a = document.getElementById("comment_form_textarea").value;

    if(a == ""){
        return;
        write ("<?php echo \"You Cannot Comment on This post, please login!\"; ?>");
    }
    else {
        if (window.XMLHttpRequest)
        {// code for IE7+, Firefox, Chrome, Opera, Safari
          xmlhttp=new XMLHttpRequest();
        }
        else
          {// code for IE6, IE5
          xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
          }
        xmlhttp.onreadystatechange=function()
          {
          if (xmlhttp.readyState==4 && xmlhttp.status==200)
            {
            document.getElementById('commentList').innerHTML=xmlhttp.responseText;
            }
          }
        xmlhttp.open("GET","newInsertComment.php?userInsert="+userName+"&"+"id="+idComment+"&text="+a,true);
        xmlhttp.send();
    }
}


// delete comment Ajax
function deleteComment (userName,idComment ){
    if(userName == ""){
        return;
        write ("<?php echo \"You Cannot Delete This Comment\"; ?>");
    }
    if (window.XMLHttpRequest)
    {// code for IE7+, Firefox, Chrome, Opera, Safari
      xmlhttp=new XMLHttpRequest();
    }
    else
      {// code for IE6, IE5
      xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
      }
    xmlhttp.onreadystatechange=function()
      {
      if (xmlhttp.readyState==4 && xmlhttp.status==200)
        {
        document.getElementById('commentList').innerHTML=xmlhttp.responseText;
        }
      }
    xmlhttp.open("GET","newDeleteComment.php?userDelete="+userName+"&"+"id="+idComment,true);
    xmlhttp.send();
}
